import request from '../../util/request'

export default {

    readArticle(id) {
        return request({
            url: 'article-histories/readArticle/' + id,
        })
    },
    logTime(id, time) {
        return request({
            url: `article-histories/logTime/${id}?time=${time}`,
        })
    },
    getArticleHistory() {
        return request({
            url: 'article-histories'
        })
    },
    getArticleHistoryChartData() {
        return request({
            url: 'article-histories/chartData'
        })
    },

    comment(articleId, content) {
        return request({
            method: 'POST',
            url: 'article-comments',
            data: {
                article: articleId,
                content
            }
        })
    },

    deleteComment(id) {
        return request({
            method: 'DELETE',
            url: `article-comments/${id}`,
        })
    },
    deleteReply(id) {
        return request({
            method: 'DELETE',
            url: `comment-replies/${id}`,
        })
    },

    getArticleComments(articleId) {
        return request({
            url: `article-comments?article.id=${articleId}`,
        })
    },


    replyComment({comment, content, to}) {
        return request({
            method: 'POST',
            url: 'comment-replies',
            data: {
                comment,
                content,
                to
            }
        })
    },


    follow(authorId) {
        return request({
            url: `relations/follow/${authorId}`
        })
    },

    unfollow(authorId) {
        return request({
            url: `relations/unfollow/${authorId}`
        })
    },


}
